# auto load
extends Node



@export var disabled: bool


# const _DAMAGE_INFO_ATTACHMENT_ANOMALY := "anomaly_text"
# const _DAMAGE_INFO_ATTACHMENT_REACTION := "reaction_text"
const _Z_INDEX := 99


func _ready() -> void:
    DamageSystem.apply_damage.connect(_show_damage)
    DamageSystem.miss_damage.connect(_show_damage)
    


func _show_damage(info: DamageInfo) -> void:
    if disabled: return
    var float_text := ObjectPoolManager.op_float_text.acquire() as FloatText
    float_text.show_damage(info)
    float_text.z_index = _Z_INDEX


func show_anomaly_text(info: DamageInfo, type: AnomalyState.Type) -> void:
    if disabled: return
    var float_text := ObjectPoolManager.op_float_text.acquire() as FloatText
    float_text.show_text(
        AnomalyState.get_type_str(type),
        info.get_damage_attribute_color(),
        info.target.float_text_posistion()
    )
    float_text.z_index = _Z_INDEX


func show_reaction_text(info: DamageInfo, type: AttributeReaction.Type) -> void:
    if disabled: return
    var float_text := ObjectPoolManager.op_float_text.acquire() as FloatText
    float_text.show_text(
        AttributeReaction.get_type_str(type),
        AttributeReaction.get_color(type),
        info.target.float_text_posistion()
    )
    float_text.z_index = _Z_INDEX
